package com.syezon.wifikey.splash.config;


import com.blankj.utilcode.util.SPUtils;

public class FrontAdConfig {

    public static final int FRONT_AD_SOURCE_SELF = 1;
    public static final int FRONT_AD_SOURCE_GDT = 2;
    public static final int FRONT_AD_SOURCE_BD = 3;
    public static final int FRONT_AD_SOURCE_TT = 4;

    public static final String ORDER_WELCOME_AD = "order_welcome_ad";
    public static final String WELCOME_AD_INFO = "welcome_ad_info";
    private static final String CONFIG_NAME = "front_ad_config";
    private static final String SPLASH_SOURCE = "SPLASH_AD_SOURCE";
    private static final String SHOW_WELCOME_INDEX = "show_welcome_index";
    private static final String LAST_FRONT_AD_SHOW_TIME = "last_front_ad_show_time";
    private static final String CAN_SHOW_AD = "can_show_ad";

    /**
     * @return 获取开屏广告来源
     */
    public static int getFrontAdSource() {
        return SPUtils.getInstance(CONFIG_NAME).getInt(SPLASH_SOURCE, FRONT_AD_SOURCE_TT);
    }

    /**
     * @param source 设置开屏广告来源
     */
    public static void setFrontAdSource(int source) {
        SPUtils.getInstance(CONFIG_NAME).put(SPLASH_SOURCE, source);
    }

    /**
     * 获取上次开屏的序号
     *
     * @return
     */
    public static int getShowFrontIndex() {
        return SPUtils.getInstance(CONFIG_NAME).getInt(SHOW_WELCOME_INDEX, 0);
    }

    /**
     * 保存上次开屏的序号
     *
     * @param
     */
    public static void saveShowFrontIndex(int index) {
        SPUtils.getInstance(CONFIG_NAME).put(SHOW_WELCOME_INDEX, index);
    }

    public static long getLastFrontAdShowTime() {
        return SPUtils.getInstance(CONFIG_NAME).getLong(LAST_FRONT_AD_SHOW_TIME, 0L);
    }

    public static void saveLastFrontAdShowTime(long lastAdShowTime) {
        SPUtils.getInstance(CONFIG_NAME).put(LAST_FRONT_AD_SHOW_TIME, lastAdShowTime);
    }

    public static boolean canShowAd() {
        return SPUtils.getInstance(CONFIG_NAME).getBoolean(CAN_SHOW_AD, false);
    }

    public static void saveCanShowAd(boolean canShow) {
        SPUtils.getInstance(CONFIG_NAME).put(CAN_SHOW_AD, canShow);
    }
}
